import { createRouter, createWebHashHistory } from 'vue-router'
import CategorySub from '@/views/Category/sub.vue'
import Goods from '@/views/Goods'
const Layout = () => import('@/views/Layout')
const Home = () => import('@/views/Home')
const TopCategory = () => import('@/views/Category')
// import Home from '../views/Home.vue'

const routes = [
  {
    path: '/',
    component: Layout,
    children: [
      { path: '/', component: Home },
      { path: '/category/:id', component: TopCategory },
      { path: '/category/sub/:id', component: CategorySub },
      // 商品详情页
      {
        path: '/goods/:id',
        component: Goods
      }
    ]
  }
//   {
//     path: '/',
//     name: 'Home',
//     component: Home
//   },
//   {
//     path: '/about',
//     name: 'About',
//     // route level code-splitting
//     // this generates a separate chunk (about.[hash].js) for this route
//     // which is lazy-loaded when the route is visited.
//     component: () => import(/* webpackChunkName: "about" */ '../views/About.vue')
//   }
]

const router = createRouter({
//   history: createWebHashHistory(),
  history: createWebHashHistory(), // createWebHashHistory() hash模式（兼容性好） | createWebHistory() history模式路由
  routes
})

export default router
